package com.tanran.taolijin.controller;

import com.tanran.taolijin.model.TaobaoAccount;
import com.tanran.taolijin.service.TaobaoService;
import com.tanran.taolijin.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Enzo Cotter on 2019/10/22.
 */
@Controller
public class TaobaoController {

    @Autowired
    private TaobaoService taobaoService;
    @GetMapping("parse")
    @ResponseBody
    public Result parse(String ml){
        return taobaoService.parse(ml.trim());
    }

    @GetMapping("loginState")
    @ResponseBody
    public Result loginState(TaobaoAccount taobaoAccount){
        return taobaoService.loginState(taobaoAccount);
    }

    @GetMapping("task")
    @ResponseBody
    public Result apply(String ml){
        return taobaoService.task(ml);
    }

    @GetMapping("createQr")
    @ResponseBody
    public Result createQr(){
        return taobaoService.createQr();
    }

    @PostMapping("checkQr")
    @ResponseBody
    public Result checkQr(TaobaoAccount taobaoAccount){
        return taobaoService.checkQr(taobaoAccount);
    }

    @PostMapping("loginQr")
    @ResponseBody
    public Result loginQr(TaobaoAccount taobaoAccount){
        return taobaoService.loginQr(taobaoAccount);
    }

    @GetMapping("test")
    public String index(){
        return "index";
    }
}
